﻿//********************************************************************************//
//创建日期：<创建日期，2016-04-19>
//创建作者：<郭登杰，guodengjie@shanghai3h.com>
//修改  ：sunxueting 2016.04.21
//功能说明：郊区县计划用水
//********************************************************************************//
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;
using BLL;
using BLL.Access;
using System.Data;
using Web.Class;
using DevExpress.Web;

namespace Web.Pages.YongShui
{
    public partial class JiaoQuXJHYS : BasePage
    {
        #region 属性

        /// <summary>
        /// 水量年
        /// </summary>
        private int ShuiLiangN
        {
            get
            {
                return Convert.ToInt32(ViewState["_ShuiLiangN"]);
            }
            set
            {
                ViewState["_ShuiLiangN"] = value;
            }
        }

        /// <summary>
        /// 水量月
        /// </summary>
        private int ShuiLiangM
        {
            get
            {
                return Convert.ToInt32(ViewState["_ShuiLiangM"]);
            }
            set
            {
                ViewState["_ShuiLiangM"] = value;
            }
        }

        /// <summary>
        /// 保存结果集1
        /// </summary>
        private DataTable dtJiHuaYS
        {
            get
            {
                return ViewState["dtJiHuaYS"] as DataTable;
            }
            set
            {
                ViewState["dtJiHuaYS"] = value;
            }
        }

        /// <summary>
        /// 当前操作项ID
        /// </summary>
        private int JiHuaYSQKID
        {
            get
            {
                return Convert.ToInt32(ViewState["JiHuaYSQKID"]);
            }
            set
            {
                ViewState["JiHuaYSQKID"] = value;
            }
        }

        /// <summary>
        /// 保存结果集2
        /// </summary>
        private DataTable dtYongShuiLYQK
        {
            get
            {
                return ViewState["dtYongShuiLYQK"] as DataTable;
            }
            set
            {
                ViewState["dtYongShuiLYQK"] = value;
            }
        }

        /// <summary>
        /// 当前操作项ID
        /// </summary>
        private int YongShuiLYQKID
        {
            get
            {
                return Convert.ToInt32(ViewState["YongShuiLYQKID"]);
            }
            set
            {
                ViewState["YongShuiLYQKID"] = value;
            }
        }

        /// <summary>
        /// 用于得到选项卡1当前操作状态
        /// </summary>
        /// <returns></returns>
        public GridViewStatus StatusTab1
        {
            get
            {
                if (ViewState["StatusTab1"] == null)
                {
                    ViewState["StatusTab1"] = GridViewStatus.Init;
                }
                return (GridViewStatus)ViewState["StatusTab1"];
            }
            set
            {
                ViewState["StatusTab1"] = value;
            }
        }
        /// <summary>
        /// 用于得到选项卡2当前操作状态
        /// </summary>
        /// <returns></returns>
        public GridViewStatus StatusTab2
        {
            get
            {
                if (ViewState["StatusTab2"] == null)
                {
                    ViewState["StatusTab2"] = GridViewStatus.Init;
                }
                return (GridViewStatus)ViewState["StatusTab2"];
            }
            set
            {
                ViewState["StatusTab2"] = value;
            }
        }



        #endregion

        #region 变量

        /// <summary>
        /// 行政区对象
        /// </summary>
        YS_JX_XINGZHENGQ _YS_JX_XINGZHENGQ = new YS_JX_XINGZHENGQ();

        /// <summary>
        /// 行政区BLL
        /// </summary>
        YS_JX_XINGZHENGQBLL _YS_JX_XINGZHENGQBLL = new YS_JX_XINGZHENGQBLL();

        /// <summary>
        /// 区县计划用水情况
        /// </summary>
        YS_QT_QUXIANJHYSQK _YS_QT_QUXIANJHYSQK = new YS_QT_QUXIANJHYSQK();

        /// <summary>
        /// 区县计划用水情况BLL
        /// </summary>
        YS_QT_QUXIANJHYSQKBLL _YS_QT_QUXIANJHYSQKBLL = new YS_QT_QUXIANJHYSQKBLL();

        /// <summary>
        /// 区县用水利用情况
        /// </summary>
        YS_QT_QUXIANYSLYQK _YS_QT_QUXIANYSLYQK = new YS_QT_QUXIANYSLYQK();

        /// <summary>
        /// 区县用水利用情况BLL
        /// </summary>
        YS_QT_QUXIANYSLYQKBLL _YS_QT_QUXIANYSLYQKBLL = new YS_QT_QUXIANYSLYQKBLL();

        /// <summary>
        /// 存储过程调用类
        /// </summary>
        SpHelper _SpHelper = new SpHelper();

        /// <summary>
        /// 操作日志BLL
        /// </summary>
        SYS_LOGBLL _SYS_LOGBLL = new SYS_LOGBLL();

        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //第一次页面加载
            if (!IsPostBack)
            {
                LoadDataTab1();
                //DisplayTab1();
                LoadDataTab2();
                //DisplayTab2();
            }
        }

        /// <summary>
        /// 绑定空表头
        /// </summary>
        protected override void Render(HtmlTextWriter sender)
        {
            DataTable dt = _YS_QT_QUXIANJHYSQKBLL.SelectYS_QT_QUXIANJHYSQKsDynamic("1=0", "", null);
            DataTable dt2 = _YS_QT_QUXIANYSLYQKBLL.SelectYS_QT_QUXIANYSLYQKsDynamic("1=0", "", null);
            base.Render(sender);
        }


        /// <summary>
        /// grid添加
        /// </summary>
        protected void tab1btnAdd_Click(object sender, EventArgs e)
        {
            this.StatusTab1 = GridViewStatus.Add;
            DisplayTab1();
        }

        /// <summary>
        /// grid添加
        /// </summary>
        protected void tab2btnAdd_Click(object sender, EventArgs e)
        {
            this.StatusTab2 = GridViewStatus.Add;
            DisplayTab2();
        }

        /// <summary>
        /// grid放弃
        /// </summary>
        protected void tab1btnCancel_Click(object sender, EventArgs e)
        {
            this.StatusTab1 = GridViewStatus.Init;
            DisplayTab1();
        }

        /// <summary>
        /// grid放弃
        /// </summary>
        protected void tab2btnCancel_Click(object sender, EventArgs e)
        {
            this.StatusTab2 = GridViewStatus.Init;
            DisplayTab2();
        }

        /// <summary>
        /// grid修改
        /// </summary>
        protected void lnbModify_Command(object sender, CommandEventArgs e)
        {
            this.JiHuaYSQKID = Convert.ToInt32(e.CommandArgument);
            this.StatusTab1 = GridViewStatus.Update;
            DisplayTab1();
            SetDataTab1();
        }

        /// <summary>
        /// grid修改
        /// </summary>
        protected void lnbModify2_Command(object sender, CommandEventArgs e)
        {
            this.YongShuiLYQKID = Convert.ToInt32(e.CommandArgument);
            this.StatusTab2 = GridViewStatus.Update;
            DisplayTab2();
            SetDataTab2();
        }

        /// <summary>
        /// grid删除
        /// </summary>
        protected void lnbDel_Command(object sender, CommandEventArgs e)
        {
            this.JiHuaYSQKID = Convert.ToInt32(e.CommandArgument);
            _YS_QT_QUXIANJHYSQK = _YS_QT_QUXIANJHYSQKBLL.SelectYS_QT_QUXIANJHYSQK(this.JiHuaYSQKID, null);

            //执行逻辑删除            
            _YS_QT_QUXIANJHYSQK.S_CAOZUOR = LoginInfo.CurrentUser.Account;
            _YS_QT_QUXIANJHYSQK.D_CAOZUOSJ = BusinessTool.GetDataBaseDateTime();
            _YS_QT_QUXIANJHYSQK.I_JLZT = -1;
            if (_YS_QT_QUXIANJHYSQKBLL.InsertOrUpdate(_YS_QT_QUXIANJHYSQK))
            {
                //_SYS_LOGBLL.Log<_YS_QT_QUXIANJHYSQK>(LoginInfo.CurrentUser, BusinessTool.WType.ToString(), "计划用水", OperateState.Delete, _YS_QT_QUXIANJHYSQK, null);
                LoadDataTab1();
                LoadGridDate1();
                //PageTools.AlertMsg(this, "操作成功！");
            }
        }

        /// <summary>
        /// grid删除
        /// </summary>
        protected void lnbDel2_Command(object sender, CommandEventArgs e)
        {
            this.YongShuiLYQKID = Convert.ToInt32(e.CommandArgument);
            _YS_QT_QUXIANYSLYQK = _YS_QT_QUXIANYSLYQKBLL.SelectYS_QT_QUXIANYSLYQK(this.YongShuiLYQKID, null);

            //执行逻辑删除            
            _YS_QT_QUXIANYSLYQK.S_CAOZUOR = LoginInfo.CurrentUser.Account;
            _YS_QT_QUXIANYSLYQK.D_CAOZUOSJ = BusinessTool.GetDataBaseDateTime();
            _YS_QT_QUXIANYSLYQK.I_JLZT = -1;
            if (_YS_QT_QUXIANYSLYQKBLL.InsertOrUpdate(_YS_QT_QUXIANYSLYQK))
            {
                //_SYS_LOGBLL.Log<_YS_QT_QUXIANJHYSQK>(LoginInfo.CurrentUser, BusinessTool.WType.ToString(), "计划用水", OperateState.Delete, _YS_QT_QUXIANJHYSQK, null);
                LoadDataTab2();
                LoadGridDate2();
                //PageTools.AlertMsg(this, "操作成功！");
            }
        }

        /// <summary>
        /// grid保存
        /// </summary>
        protected void tab1btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateDataTab1())
            {
                SaveDataTab1();
            }
        }

        /// <summary>
        /// grid保存
        /// </summary>
        protected void tab2btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateDataTab2())
            {
                SaveDataTab2();
            }
        }

        /// <summary>
        /// 保存验证
        /// </summary>
        private bool ValidateDataTab1()
        {
            if (this.cmbquxian.Text == "")
            {
                //PageTools.AlertMsg(this,"请选择区县");
                return false;
            }
            return true;
        }

        /// <summary>
        /// 保存验证
        /// </summary>
        private bool ValidateDataTab2()
        {
            return true;
        }

        /// <summary>
        /// 查询区县信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnChaZhao_Click(object sender, EventArgs e)
        {
            LoadGridDate1();
        }



        /// <summary>
        /// tab2页签查询事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnChaZhao2_Click(object sender, EventArgs e)
        {
            LoadGridDate2();
        }

        /// <summary>
        /// tab1导出excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnExportExcel_Click(object sender, EventArgs e)
        {
            if (this.dtJiHuaYS == null || this.dtJiHuaYS.Rows.Count < 1)
            {
                //PageTools.AlertMsg(this, "没有符合的数据导出");
            }
            else
            {
                PageTools.ExportExcel(this.dtJiHuaYS);
            }
        }

        /// <summary>
        /// tab1打印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnPrint_Click(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// tab2导出excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnExportExcel2_Click(object sender, EventArgs e)
        {
            if (this.dtYongShuiLYQK == null || this.dtYongShuiLYQK.Rows.Count < 1)
            {
                //PageTools.AlertMsg(this, "没有符合的数据导出");
            }
            else
            {
                PageTools.ExportExcel(this.dtYongShuiLYQK);
            }
        }

        /// <summary>
        /// tab2打印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnPrint2_Click(object sender, EventArgs e)
        {

        }
        #endregion

        #region 方法

        /// <summary>
        /// 数据加载
        /// </summary>
        private void LoadDataTab1()
        {
            //水量年月
            string water_y_m = BusinessTool.YS_GETSETTINGSVALUE(eSETTINGS_KEYNAME.WATER_Y_M.ToString());
            this.ShuiLiangN = Convert.ToInt32(water_y_m.Substring(0, 4));
            this.ShuiLiangM = Convert.ToInt32(water_y_m.Substring(4, 2));

            for (int i = this.ShuiLiangN - 5; i < this.ShuiLiangN + 5; i++)
            {
                cmbShuiLiangN.Items.Add(i.ToString());
            }
            cmbShuiLiangN.SelectedIndex = 5;

            cmbShuiLiangY.Items.Add("全部");

            for (int i = 1; i < 13; i++)
            {
                cmbShuiLiangY.Items.Add(i.ToString());
            }
            cmbShuiLiangY.SelectedIndex = this.ShuiLiangM;
            txtShuiLiangNY.Text = water_y_m;
            //加载区信息
            LoadXingZhengQ();
        }

        /// <summary>
        /// 加载用水利用情况
        /// </summary>
        private void LoadDataTab2()
        {

            for (int i = this.ShuiLiangN - 5; i < this.ShuiLiangN + 5; i++)
            {
                cmbShuiLiangN2.Items.Add(i.ToString());
            }
            cmbShuiLiangN2.SelectedIndex = 5;

            cmbShuiLiangY2.Items.Add("全部");
            for (int i = 1; i < 13; i++)
            {
                cmbShuiLiangY2.Items.Add(i.ToString());
            }
            txtShuiLiangNY2.Text = BusinessTool.YS_GETSETTINGSVALUE(eSETTINGS_KEYNAME.WATER_Y_M.ToString());
            cmbShuiLiangY2.SelectedIndex = this.ShuiLiangM;
            //加载区信息
            //LoadXingZhengQTab2();
        }

        /// <summary>
        /// 加载区信息
        /// </summary>
        public void LoadXingZhengQ()
        {
            //DataTable QuXX = _YS_JX_XINGZHENGQBLL.SelectYS_JX_XINGZHENGQsDynamic("i_jlzt=0 and s_bianhao is not null", null);
            //for (int i = 0; i < QuXX.Rows.Count; i++)
            //{
            //    string quxian = QuXX.Rows[i]["s_mingcheng"].ToString();
            //    cmbquxian.Items.Add(quxian);
            //    cmbQuXianTab2.Items.Add(quxian);

            //}

            string[] arr = { "嘉定", "南汇", "奉贤", "松江", "金山", "青浦", "崇明" };
            for (int i = 0; i < arr.Length; i++)
            {
                cmbquxian.Items.Add(arr[i]);
                cmbQuXianTab2.Items.Add(arr[i]);

                cbmQuXian.Items.Add(arr[i]);
                cmbquxian2.Items.Add(arr[i]);
            }

        }

        ///// <summary>
        ///// 加载区信息2
        ///// </summary>
        //public void LoadXingZhengQTab2()
        //{
        //    DataTable QuXX = _YS_JX_XINGZHENGQBLL.SelectYS_JX_XINGZHENGQsDynamic("i_jlzt=0 and s_bianhao is not null", null);
        //    for (int i = 0; i < QuXX.Rows.Count; i++)
        //    {
        //        string quxian = QuXX.Rows[i]["s_mingcheng"].ToString();
        //        cmbQuXianTab2.Items.Add(quxian);
        //        cmbquxian2.Items.Add(quxian);
        //    }

        //}

        /// <summary>
        ///用于控制添加、修改、查看三种状态的显示
        /// </summary>
        private void DisplayTab1()
        {
            switch (this.StatusTab1)
            {
                case GridViewStatus.Init:
                    tab1btnAdd.Visible = true;
                    tab1GridViewContentTable.Visible = false;
                    this.gvJiHuaYS.Enabled = true;
                    break;
                case GridViewStatus.Search:
                    tab1btnAdd.Visible = true;
                    tab1GridViewContentTable.Visible = true;
                    break;
                case GridViewStatus.Update:
                    tab1btnAdd.Visible = false;
                    tab1GridViewContentTable.Visible = true;
                    this.gvJiHuaYS.Enabled = false;
                    //this.tab1lblOperateTip.Text = "修改";
                    break;
                case GridViewStatus.Add:
                    tab1btnAdd.Visible = false;
                    tab1GridViewContentTable.Visible = true;
                    this.gvJiHuaYS.Enabled = false;
                    //this.tab1lblOperateTip.Text = "添加";
                    txtShuiLiangNY.Text = (Convert.ToInt32(this.ShuiLiangN) * 100 + Convert.ToInt32(this.ShuiLiangM)).ToString();
                    LoadXingZhengQ();
                    break;
            }
        }

        /// <summary>
        ///用于控制添加、修改、查看三种状态的显示
        /// </summary>
        private void DisplayTab2()
        {
            switch (this.StatusTab2)
            {
                case GridViewStatus.Init:
                    tab2btnAdd.Visible = true;
                    tab2GridViewContentTable.Visible = false;
                    this.gvYongShuiLYQK.Enabled = true;
                    break;
                case GridViewStatus.Search:
                    tab2btnAdd.Visible = true;
                    tab2GridViewContentTable.Visible = true;
                    break;
                case GridViewStatus.Update:
                    tab2btnAdd.Visible = false;
                    tab2GridViewContentTable.Visible = true;
                    this.gvYongShuiLYQK.Enabled = false;
                    //this.tab2lblOperateTip.Text = "修改";
                    break;
                case GridViewStatus.Add:
                    tab2btnAdd.Visible = false;
                    tab2GridViewContentTable.Visible = true;
                    this.gvYongShuiLYQK.Enabled = false;
                    //this.tab2lblOperateTip.Text = "添加";
                    txtShuiLiangNY2.Text = (Convert.ToInt32(this.ShuiLiangN) * 100 + Convert.ToInt32(this.ShuiLiangM)).ToString();
                    //LoadXingZhengQTab2();
                    break;
            }
        }

        /// <summary>
        /// 保存数据tab1
        /// </summary>
        private void SaveDataTab1()
        {
            OperateState operateState;
            //添加
            if (this.StatusTab1 == GridViewStatus.Add)
            {
                _YS_QT_QUXIANJHYSQK.ID = 0;
                _YS_QT_QUXIANJHYSQK.I_JLZT = 0;
                operateState = OperateState.Add;
            }
            //修改
            else
            {
                //修改操作
                _YS_QT_QUXIANJHYSQK = _YS_QT_QUXIANJHYSQKBLL.SelectYS_QT_QUXIANJHYSQK(this.JiHuaYSQKID, null);
                operateState = OperateState.Modify;
            }

            //水量年月
            _YS_QT_QUXIANJHYSQK.I_YM = Convert.ToInt32(txtShuiLiangNY.Text);
            //区县
            _YS_QT_QUXIANJHYSQK.S_QUXIAN = cbmQuXian.Text;
            //计划户数
            _YS_QT_QUXIANJHYSQK.I_HEJIHS = Convert.ToInt32(txtJiHuaH_HJ.Text != "" ? txtJiHuaH_HJ.Text : "0");
            _YS_QT_QUXIANJHYSQK.I_GONGYEHS = Convert.ToInt32(txtJiHuaH_GY.Text != "" ? txtJiHuaH_GY.Text : "0");
            _YS_QT_QUXIANJHYSQK.I_FEIGONGYHS = Convert.ToInt32(txtJiHuaH_FGY.Text != "" ? txtJiHuaH_FGY.Text : "0");
            //计划水量
            _YS_QT_QUXIANJHYSQK.I_HEJIJHL = Convert.ToDecimal(txtJiHuaS_HJ.Text != "" ? txtJiHuaS_HJ.Text : "0");
            _YS_QT_QUXIANJHYSQK.I_GONGYEJHL = Convert.ToDecimal(txtJiHuaS_GY.Text != "" ? txtJiHuaS_GY.Text : "0");
            _YS_QT_QUXIANJHYSQK.I_FEIGONGYJHL = Convert.ToDecimal(txtJiHuaS_FGY.Text != "" ? txtJiHuaS_FGY.Text : "0");
            //新水量
            _YS_QT_QUXIANJHYSQK.I_HEJIXSL = Convert.ToDecimal(txtXinShuiL_HJ.Text != "" ? txtXinShuiL_HJ.Text : "0");
            _YS_QT_QUXIANJHYSQK.I_GONGYEXSL = Convert.ToDecimal(txtXinShuiL_GY.Text != "" ? txtXinShuiL_GY.Text : "0");
            _YS_QT_QUXIANJHYSQK.I_FEIGONGYXSL = Convert.ToDecimal(txtXinShuiL_FGY.Text != "" ? txtXinShuiL_FGY.Text : "0");
            //加价水量
            _YS_QT_QUXIANJHYSQK.I_HEJIJJL = Convert.ToDecimal(txtJiaJiaSL_HJ.Text != "" ? txtJiaJiaSL_HJ.Text : "0");
            _YS_QT_QUXIANJHYSQK.I_GONGYEJJL = Convert.ToDecimal(txtJiaJiaSL_GY.Text != "" ? txtJiaJiaSL_GY.Text : "0");
            _YS_QT_QUXIANJHYSQK.I_FEIGONGYJJL = Convert.ToDecimal(txtJiaJiaSL_FGY.Text != "" ? txtJiaJiaSL_FGY.Text : "0");
            //加价水费
            _YS_QT_QUXIANJHYSQK.N_HEJIJJF = Convert.ToDouble(txtJiaJiaSF_HJ.Text != "" ? txtJiaJiaSF_HJ.Text : "0");
            _YS_QT_QUXIANJHYSQK.N_GONGYEJJF = Convert.ToDouble(txtJiaJiaSF_GY.Text != "" ? txtJiaJiaSF_GY.Text : "0");
            _YS_QT_QUXIANJHYSQK.N_FEIGONGYJJF = Convert.ToDouble(txtJiaJiaSF_FGY.Text != "" ? txtJiaJiaSF_FGY.Text : "0");
            //计划完成率
            _YS_QT_QUXIANJHYSQK.N_JIHUAWCL = Convert.ToDouble(txtJiaHuaWCL.Text != "" ? txtJiaHuaWCL.Text : "0");
            //供水总量
            _YS_QT_QUXIANJHYSQK.I_GONGSHUIZL = Convert.ToDecimal(txtGongShuiZL.Text != "" ? txtGongShuiZL.Text : "0");
            //计划用水率
            _YS_QT_QUXIANJHYSQK.N_JIHUAYSL = Convert.ToDouble(txtJiaHuaYSL.Text != "" ? txtJiaHuaYSL.Text : "0");
            //水平衡户数
            _YS_QT_QUXIANJHYSQK.I_SHUIPINGHHS = Convert.ToInt32(txtShuiPingWCHS.Text != "" ? txtShuiPingWCHS.Text : "0");
            //节水项目数
            _YS_QT_QUXIANJHYSQK.I_JIESHUIXMS = Convert.ToInt32(txtJieShuiXMS.Text != "" ? txtJieShuiXMS.Text : "0");
            //最高日节水量
            _YS_QT_QUXIANJHYSQK.I_ZUIGAORJSL = Convert.ToDecimal(txtZuiGaoRJSL.Text != "" ? txtZuiGaoRJSL.Text : "0");
            //节水项目资金
            _YS_QT_QUXIANJHYSQK.N_JIESHUIZJ = Convert.ToDouble(txtJieShuiXMZJ.Text != "" ? txtJieShuiXMZJ.Text : "0");
            //自筹资金
            _YS_QT_QUXIANJHYSQK.N_ZICHOUZJ = Convert.ToDouble(txtZiChouZJ.Text != "" ? txtZiChouZJ.Text : "0");
            //节水器具安装件套数
            _YS_QT_QUXIANJHYSQK.I_JIESHUIQTS = Convert.ToInt32(txtJieShuiQJTS.Text != "" ? txtJieShuiQJTS.Text : "0");
            //节水器具安装日节水量
            _YS_QT_QUXIANJHYSQK.I_JIESHUIQJSL = Convert.ToDecimal(txtJieShuiQJSL.Text != "" ? txtJieShuiQJSL.Text : "0");
            //财政节水资金投入
            _YS_QT_QUXIANJHYSQK.N_CAIZHENGJSZJ = Convert.ToDouble(txtCaiZhengZJTR.Text != "" ? txtCaiZhengZJTR.Text : "0");

            _YS_QT_QUXIANJHYSQK.S_CAOZUOR = this.UserID.ToString();
            _YS_QT_QUXIANJHYSQK.D_CAOZUOSJ = BusinessTool.GetDataBaseDateTime();
            bool success = _YS_QT_QUXIANJHYSQKBLL.InsertOrUpdate(_YS_QT_QUXIANJHYSQK, null);
            if (success)
            {
                PageTools.AlertMsg(this, "保存成功！");
                this.StatusTab1 = GridViewStatus.Init;
                DisplayTab1();
                LoadGridDate1();
            }
            else
            {
                PageTools.AlertMsg(this, "保存失败！");
            }
        }

        /// <summary>
        /// 保存数据tab2
        /// </summary>
        private void SaveDataTab2()
        {
            OperateState operateState;
            //添加
            if (this.StatusTab2 == GridViewStatus.Add)
            {
                //获取当前数据的最大id
                //int id = Convert.ToInt32(_SpHelper.P_YSQT_GETMAXID().Tables[0].Rows[0]["ysly"]) + 1;
                _YS_QT_QUXIANYSLYQK.ID = 0;
                _YS_QT_QUXIANYSLYQK.I_JLZT = 0;
                operateState = OperateState.Add;
            }
            //修改
            else
            {
                //修改操作
                _YS_QT_QUXIANYSLYQK = _YS_QT_QUXIANYSLYQKBLL.SelectYS_QT_QUXIANYSLYQK(this.YongShuiLYQKID, null);
                operateState = OperateState.Modify;
            }

            //水量年月
            _YS_QT_QUXIANYSLYQK.I_YM = Convert.ToDecimal(txtShuiLiangNY2.Text);
            //区县
            _YS_QT_QUXIANYSLYQK.S_QUXIAN = cmbquxian2.Text;
            //工业用新水量
            _YS_QT_QUXIANYSLYQK.I_GONGYEXSL = Convert.ToDecimal(txtGongYeXSL.Text != "" ? txtGongYeXSL.Text : "0");
            //冷却新水量
            _YS_QT_QUXIANYSLYQK.I_LENGQUEXSL = Convert.ToDecimal(txtLengQueXSL.Text != "" ? txtLengQueXSL.Text : "0");
            //工业用水重复利用量
            _YS_QT_QUXIANYSLYQK.I_GONGYECFL = Convert.ToDecimal(txtGongYeCFL.Text != "" ? txtGongYeCFL.Text : "0");
            //间接冷却水循环量
            _YS_QT_QUXIANYSLYQK.I_LENGQUEXHL = Convert.ToDecimal(txtLengQueXHL.Text != "" ? txtLengQueXHL.Text : "0");
            //工业用水重复利用率
            _YS_QT_QUXIANYSLYQK.N_GONGYECFL = Convert.ToDouble(txtGongYeCFLv.Text != "" ? txtGongYeCFLv.Text : "0");
            //间接冷却水循环率
            _YS_QT_QUXIANYSLYQK.N_LENGQUEXHL = Convert.ToDouble(txtLengQueXHLv.Text != "" ? txtLengQueXHLv.Text : "0");
            //锅炉产汽量
            _YS_QT_QUXIANYSLYQK.I_GUOLUCQL = Convert.ToDecimal(txtGuoLuCQL.Text != "" ? txtGuoLuCQL.Text : "0");
            //工艺用新水量
            _YS_QT_QUXIANYSLYQK.I_GONGYIXSL = Convert.ToDecimal(txtGongYiXSL.Text != "" ? txtGongYiXSL.Text : "0");
            //锅炉蒸汽冷凝水回用量
            _YS_QT_QUXIANYSLYQK.I_GUOLUHYL = Convert.ToDecimal(txtGuoLuHYL.Text != "" ? txtGuoLuHYL.Text : "0");
            //工艺水回用量
            _YS_QT_QUXIANYSLYQK.I_GONGYIHYL = Convert.ToDecimal(txtGongYiHYL.Text != "" ? txtGongYiHYL.Text : "0");
            //锅炉蒸汽冷凝水回用率
            _YS_QT_QUXIANYSLYQK.N_GUOLUHYL = Convert.ToDouble(txtGuoLuHYLv.Text != "" ? txtGuoLuHYLv.Text : "0");
            //工艺水回用率
            _YS_QT_QUXIANYSLYQK.N_GONGYIHYL = Convert.ToDouble(txtGongYiHYLv.Text != "" ? txtGongYiHYLv.Text : "0");
            //工业总产值(现金)
            _YS_QT_QUXIANYSLYQK.I_GONGYEZCZ = Convert.ToDecimal(txtGongYeZCZ.Text != "" ? txtGongYeZCZ.Text : "0");
            //万元产值新水量
            _YS_QT_QUXIANYSLYQK.N_WANYUANXSL = Convert.ToDouble(txtWanYuanXSL.Text != "" ? txtWanYuanXSL.Text : "0");
            //城市公共用新水量
            _YS_QT_QUXIANYSLYQK.I_CHENGSHIXSL = Convert.ToDecimal(txtChengShiXSL.Text != "" ? txtChengShiXSL.Text : "0");
            //间接冷却用新水量
            _YS_QT_QUXIANYSLYQK.I_JIANJIEXSL = Convert.ToDecimal(txtLengQueXSL2.Text != "" ? txtLengQueXSL2.Text : "0");
            //城市公共用水重复利用量
            _YS_QT_QUXIANYSLYQK.I_CHENGSHICFL = Convert.ToDecimal(txtChengShiLYL.Text != "" ? txtChengShiLYL.Text : "0");
            //间接冷却水循环量
            _YS_QT_QUXIANYSLYQK.I_JIANJIEXHL = Convert.ToDecimal(txtLengQueXHL2.Text != "" ? txtLengQueXHL2.Text : "0");
            //城市公共用水重复利用率
            _YS_QT_QUXIANYSLYQK.N_CHENGSHICFL = Convert.ToDouble(txtChengShiLYLv.Text != "" ? txtChengShiLYLv.Text : "0");
            //间接冷却水循环率
            _YS_QT_QUXIANYSLYQK.N_JIANJIEXHL = Convert.ToDouble(txtLengQueXHLv2.Text != "" ? txtLengQueXHLv2.Text : "0");
            //非常规
            _YS_QT_QUXIANYSLYQK.I_FEICHANGGSL = Convert.ToDecimal(txtFeiChangGSL.Text != "" ? txtFeiChangGSL.Text : "0");
            //海水利用量
            _YS_QT_QUXIANYSLYQK.I_HAISHUILYL = Convert.ToDecimal(txtHaiShuiLYL.Text != "" ? txtHaiShuiLYL.Text : "0");
            //雨水利用量
            _YS_QT_QUXIANYSLYQK.I_YUSHUILYL = Convert.ToDecimal(txtYuShuiLYL.Text != "" ? txtYuShuiLYL.Text : "0");

            _YS_QT_QUXIANYSLYQK.S_CAOZUOR = this.UserID.ToString();
            _YS_QT_QUXIANYSLYQK.D_CAOZUOSJ = BusinessTool.GetDataBaseDateTime();
            bool success = _YS_QT_QUXIANYSLYQKBLL.InsertOrUpdate(_YS_QT_QUXIANYSLYQK, null);
            if (success)
            {
                PageTools.AlertMsg(this, "保存成功！");
                this.StatusTab2 = GridViewStatus.Init;
                DisplayTab2();
                LoadGridDate2();
            }
            else
            {
                PageTools.AlertMsg(this, "保存失败！");
            }
        }

        /// <summary>
        /// 给输入框赋值
        /// </summary>
        private void SetDataTab1()
        {
            _YS_QT_QUXIANJHYSQK = _YS_QT_QUXIANJHYSQKBLL.SelectYS_QT_QUXIANJHYSQK(this.JiHuaYSQKID, null);
            //水量年月
            txtShuiLiangNY.Text = _YS_QT_QUXIANJHYSQK.I_YM.ToString();
            //区县
            cbmQuXian.Text = _YS_QT_QUXIANJHYSQK.S_QUXIAN.ToString();
            cbmQuXian.Enabled = false;
            //计划户数
            txtJiHuaH_HJ.Text = _YS_QT_QUXIANJHYSQK.I_HEJIHS.ToString();
            txtJiHuaH_GY.Text = _YS_QT_QUXIANJHYSQK.I_GONGYEHS.ToString();
            txtJiHuaH_FGY.Text = _YS_QT_QUXIANJHYSQK.I_FEIGONGYHS.ToString();
            //计划水量
            txtJiHuaS_HJ.Text = _YS_QT_QUXIANJHYSQK.I_HEJIJHL.ToString();
            txtJiHuaS_GY.Text = _YS_QT_QUXIANJHYSQK.I_GONGYEJHL.ToString();
            txtJiHuaS_FGY.Text = _YS_QT_QUXIANJHYSQK.I_FEIGONGYJHL.ToString();
            //新水量
            txtXinShuiL_HJ.Text = _YS_QT_QUXIANJHYSQK.I_HEJIXSL.ToString();
            txtXinShuiL_GY.Text = _YS_QT_QUXIANJHYSQK.I_GONGYEXSL.ToString();
            txtXinShuiL_FGY.Text = _YS_QT_QUXIANJHYSQK.I_FEIGONGYXSL.ToString();
            //加价水量
            txtJiaJiaSL_HJ.Text = _YS_QT_QUXIANJHYSQK.I_HEJIJJL.ToString();
            txtJiaJiaSL_GY.Text = _YS_QT_QUXIANJHYSQK.I_GONGYEJJL.ToString();
            txtJiaJiaSL_FGY.Text = _YS_QT_QUXIANJHYSQK.I_FEIGONGYJJL.ToString();
            //加价水费
            txtJiaJiaSF_HJ.Text = _YS_QT_QUXIANJHYSQK.N_HEJIJJF.ToString();
            txtJiaJiaSF_GY.Text = _YS_QT_QUXIANJHYSQK.N_GONGYEJJF.ToString();
            txtJiaJiaSF_FGY.Text = _YS_QT_QUXIANJHYSQK.N_FEIGONGYJJF.ToString();
            //计划完成率
            txtJiaHuaWCL.Text = _YS_QT_QUXIANJHYSQK.N_JIHUAWCL.ToString();
            //供水总量
            txtGongShuiZL.Text = _YS_QT_QUXIANJHYSQK.I_GONGSHUIZL.ToString();
            //计划用水率
            txtJiaHuaYSL.Text = _YS_QT_QUXIANJHYSQK.N_JIHUAYSL.ToString();
            //水平衡户数
            txtShuiPingWCHS.Text = _YS_QT_QUXIANJHYSQK.I_SHUIPINGHHS.ToString();
            //节水项目数
            txtJieShuiXMS.Text = _YS_QT_QUXIANJHYSQK.I_JIESHUIXMS.ToString();
            //最高日节水量
            txtZuiGaoRJSL.Text = _YS_QT_QUXIANJHYSQK.I_ZUIGAORJSL.ToString();
            //节水项目资金
            txtJieShuiXMZJ.Text = _YS_QT_QUXIANJHYSQK.N_JIESHUIZJ.ToString();
            //自筹资金
            txtZiChouZJ.Text = _YS_QT_QUXIANJHYSQK.N_ZICHOUZJ.ToString();
            //节水器具安装件套数
            txtJieShuiQJTS.Text = _YS_QT_QUXIANJHYSQK.I_JIESHUIQTS.ToString();
            //节水器具安装日节水量
            txtJieShuiQJSL.Text = _YS_QT_QUXIANJHYSQK.I_JIESHUIQJSL.ToString();
            //财政节水资金投入
            txtCaiZhengZJTR.Text = _YS_QT_QUXIANJHYSQK.N_CAIZHENGJSZJ.ToString();
        }

        /// <summary>
        /// 给输入框赋值Tab2
        /// </summary>
        private void SetDataTab2()
        {
            _YS_QT_QUXIANYSLYQK = _YS_QT_QUXIANYSLYQKBLL.SelectYS_QT_QUXIANYSLYQK(this.YongShuiLYQKID, null);
            //水量年月
            txtShuiLiangNY2.Text = _YS_QT_QUXIANYSLYQK.I_YM.ToString();
            //区县
            cmbquxian2.Text = _YS_QT_QUXIANYSLYQK.S_QUXIAN.ToString();
            cmbquxian2.Enabled = false;
            //工业用新水量
            txtGongYeXSL.Text = _YS_QT_QUXIANYSLYQK.I_GONGYEXSL.ToString();
            //冷却新水量
            txtLengQueXSL.Text = _YS_QT_QUXIANYSLYQK.I_LENGQUEXSL.ToString();
            //工业用水重复利用量
            txtGongYeCFL.Text = _YS_QT_QUXIANYSLYQK.I_GONGYECFL.ToString();
            //间接冷却水循环量
            txtLengQueXHL.Text = _YS_QT_QUXIANYSLYQK.I_LENGQUEXHL.ToString();
            //工业用水重复利用率
            txtGongYeCFLv.Text = _YS_QT_QUXIANYSLYQK.N_GONGYECFL.ToString();
            //间接冷却水循环率
            txtLengQueXHLv.Text = _YS_QT_QUXIANYSLYQK.N_LENGQUEXHL.ToString();
            //锅炉产汽量
            txtGuoLuCQL.Text = _YS_QT_QUXIANYSLYQK.I_GUOLUCQL.ToString();
            //工艺用新水量
            txtGongYiXSL.Text = _YS_QT_QUXIANYSLYQK.I_GONGYIXSL.ToString();
            //锅炉蒸汽冷凝水回用量
            txtGuoLuHYL.Text = _YS_QT_QUXIANYSLYQK.I_GUOLUHYL.ToString();
            //工艺水回用量
            txtGongYiHYL.Text = _YS_QT_QUXIANYSLYQK.I_GONGYIHYL.ToString();
            //锅炉蒸汽冷凝水回用率
            txtGuoLuHYLv.Text = _YS_QT_QUXIANYSLYQK.N_GUOLUHYL.ToString();
            //工艺水回用率
            txtGongYiHYLv.Text = _YS_QT_QUXIANYSLYQK.N_GONGYIHYL.ToString();
            //工业总产值(现金)
            txtGongYeZCZ.Text = _YS_QT_QUXIANYSLYQK.I_GONGYEZCZ.ToString();
            //万元产值新水量
            txtWanYuanXSL.Text = _YS_QT_QUXIANYSLYQK.N_WANYUANXSL.ToString();
            //城市公共用新水量
            txtChengShiXSL.Text = _YS_QT_QUXIANYSLYQK.I_CHENGSHIXSL.ToString();
            //间接冷却用新水量
            txtLengQueXSL2.Text = _YS_QT_QUXIANYSLYQK.I_JIANJIEXSL.ToString();
            //城市公共用水重复利用量
            txtChengShiLYL.Text = _YS_QT_QUXIANYSLYQK.I_CHENGSHICFL.ToString();
            //间接冷却水循环量
            txtLengQueXHL2.Text = _YS_QT_QUXIANYSLYQK.I_JIANJIEXHL.ToString();
            //城市公共用水重复利用率
            txtChengShiLYLv.Text = _YS_QT_QUXIANYSLYQK.N_CHENGSHICFL.ToString();
            //间接冷却水循环率
            txtLengQueXHLv2.Text = _YS_QT_QUXIANYSLYQK.N_JIANJIEXHL.ToString();
            //非常规
            txtFeiChangGSL.Text = _YS_QT_QUXIANYSLYQK.I_FEICHANGGSL.ToString();
            //海水利用量
            txtHaiShuiLYL.Text = _YS_QT_QUXIANYSLYQK.I_HAISHUILYL.ToString();
            //雨水利用量
            txtYuShuiLYL.Text = _YS_QT_QUXIANYSLYQK.I_YUSHUILYL.ToString();

        }

        /// <summary>
        /// 显示grid计划用水
        /// </summary>
        private void LoadGridDate1()
        {
            string year = cmbShuiLiangN.Text;
            string month = cmbShuiLiangY.Text;
            string area = cmbquxian.Text;
            string condition = " I_JLZT=0   ";

            if (month != "全部")
            {
                condition += "AND I_YM =" + (Convert.ToInt32(year) * 100 + Convert.ToInt32(month));
            }
            else
            {
                condition += "AND I_YM like '{0}%' ";
            }


            if (area != "全部")
            {
                condition += " AND  S_QUXIAN='{1}'  ";
            }
            this.dtJiHuaYS = _YS_QT_QUXIANJHYSQKBLL.SelectYS_QT_QUXIANJHYSQKsDynamic(string.Format(condition, year, area), "i_ym");
            this.gvJiHuaYS.DataSource = this.dtJiHuaYS;
            this.gvJiHuaYS.DataBind();
            labZongJiLu.Text = "共有" + this.dtJiHuaYS.Rows.Count.ToString() + "条记录";
        }

        /// <summary>
        /// 加载tab2页签grid
        /// </summary>
        private void LoadGridDate2()
        {
            string year = cmbShuiLiangN2.Text;
            string month = cmbShuiLiangY2.Text;
            string area = cmbQuXianTab2.Text;
            string condition = " I_JLZT=0   ";

            if (month != "全部")
            {
                condition += "AND I_YM =" + (Convert.ToInt32(year) * 100 + Convert.ToInt32(month));
            }
            else
            {
                condition += "AND I_YM like '{0}%' ";
            }


            if (area != "全部")
            {
                condition += " AND  S_QUXIAN='{1}'  ";
            }
            this.dtYongShuiLYQK = _YS_QT_QUXIANYSLYQKBLL.SelectYS_QT_QUXIANYSLYQKsDynamic(string.Format(condition, year, area), "i_ym");
            this.gvYongShuiLYQK.DataSource = this.dtYongShuiLYQK;
            this.gvYongShuiLYQK.DataBind();
            labZongJiLu2.Text = "共有" + this.dtYongShuiLYQK.Rows.Count.ToString() + "条记录";
        }

        #endregion

        /// <summary>
        /// 响应前台回调
        /// </summary>
        protected void ASPxCallback1_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        {

            if (e.Parameter == "edit")
            {
                int id = Convert.ToInt32(this.hdCollection.Get("ID"));
                _YS_QT_QUXIANJHYSQK = _YS_QT_QUXIANJHYSQKBLL.SelectYS_QT_QUXIANJHYSQK(id, null);
                e.Result = string.Join("|", e.Parameter, "0", "success",
                     _YS_QT_QUXIANJHYSQK.I_YM.ToString(), _YS_QT_QUXIANJHYSQK.S_QUXIAN.ToString(), _YS_QT_QUXIANJHYSQK.I_HEJIHS.ToString(),
                     _YS_QT_QUXIANJHYSQK.I_GONGYEHS.ToString(), _YS_QT_QUXIANJHYSQK.I_FEIGONGYHS.ToString(), _YS_QT_QUXIANJHYSQK.I_HEJIJHL.ToString(),
                     _YS_QT_QUXIANJHYSQK.I_GONGYEJHL.ToString(), _YS_QT_QUXIANJHYSQK.I_FEIGONGYJHL.ToString(), _YS_QT_QUXIANJHYSQK.I_HEJIXSL.ToString(),
                     _YS_QT_QUXIANJHYSQK.I_GONGYEXSL.ToString(), _YS_QT_QUXIANJHYSQK.I_FEIGONGYXSL.ToString(), _YS_QT_QUXIANJHYSQK.I_HEJIJJL.ToString(),
                     _YS_QT_QUXIANJHYSQK.I_GONGYEJJL.ToString(), _YS_QT_QUXIANJHYSQK.I_FEIGONGYJJL.ToString(), _YS_QT_QUXIANJHYSQK.N_HEJIJJF.ToString(),
                    _YS_QT_QUXIANJHYSQK.N_GONGYEJJF.ToString(), _YS_QT_QUXIANJHYSQK.N_FEIGONGYJJF.ToString(), _YS_QT_QUXIANJHYSQK.N_JIHUAWCL.ToString(),
                     _YS_QT_QUXIANJHYSQK.I_GONGSHUIZL.ToString(), _YS_QT_QUXIANJHYSQK.N_JIHUAYSL.ToString(), _YS_QT_QUXIANJHYSQK.I_SHUIPINGHHS.ToString(),
                     _YS_QT_QUXIANJHYSQK.I_JIESHUIXMS.ToString(), _YS_QT_QUXIANJHYSQK.I_ZUIGAORJSL.ToString(), _YS_QT_QUXIANJHYSQK.N_JIESHUIZJ.ToString(),
                     _YS_QT_QUXIANJHYSQK.N_ZICHOUZJ.ToString(), _YS_QT_QUXIANJHYSQK.I_JIESHUIQTS.ToString(), _YS_QT_QUXIANJHYSQK.I_JIESHUIQJSL.ToString(),
                    _YS_QT_QUXIANJHYSQK.N_CAIZHENGJSZJ.ToString());
            }
            else if (e.Parameter == "del")
            {
                int id = Convert.ToInt32(this.hdCollection.Get("ID"));
                _YS_QT_QUXIANJHYSQK = _YS_QT_QUXIANJHYSQKBLL.SelectYS_QT_QUXIANJHYSQK(id, null);

                //执行逻辑删除            
                _YS_QT_QUXIANJHYSQK.S_CAOZUOR = LoginInfo.CurrentUser.Account;
                _YS_QT_QUXIANJHYSQK.D_CAOZUOSJ = BusinessTool.GetDataBaseDateTime();
                _YS_QT_QUXIANJHYSQK.I_JLZT = -1;
                _SYS_LOGBLL.Log<YS_QT_QUXIANJHYSQK>(LoginInfo.CurrentUser, BusinessTool.WType.ToString(), "计划用水情况", OperateState.Delete, _YS_QT_QUXIANJHYSQK, null);
                if (_YS_QT_QUXIANJHYSQKBLL.InsertOrUpdate(_YS_QT_QUXIANJHYSQK))
                {


                }
                e.Result = e.Parameter + "|0|操作成功！";
            }
            else if (e.Parameter == "save")
            {
                OperateState operateState;
                int id = Convert.ToInt32(this.hdCollection.Get("ID"));
                //添加
                if (id <= 0)
                {
                    operateState = OperateState.Add;
                    _YS_QT_QUXIANJHYSQK.ID = 0;
                    _YS_QT_QUXIANJHYSQK.I_JLZT = 0;
                    
                }
                //修改
                else
                {
                    //修改操作
                    _YS_QT_QUXIANJHYSQK = _YS_QT_QUXIANJHYSQKBLL.SelectYS_QT_QUXIANJHYSQK(id, null);
                    operateState = OperateState.Modify;
                }

                //水量年月
                _YS_QT_QUXIANJHYSQK.I_YM = Convert.ToInt32(txtShuiLiangNY.Text);
                //区县
                _YS_QT_QUXIANJHYSQK.S_QUXIAN = cbmQuXian.Text;
                //计划户数
                _YS_QT_QUXIANJHYSQK.I_HEJIHS = Convert.ToInt32(txtJiHuaH_HJ.Text != "" ? txtJiHuaH_HJ.Text : "0");
                _YS_QT_QUXIANJHYSQK.I_GONGYEHS = Convert.ToInt32(txtJiHuaH_GY.Text != "" ? txtJiHuaH_GY.Text : "0");
                _YS_QT_QUXIANJHYSQK.I_FEIGONGYHS = Convert.ToInt32(txtJiHuaH_FGY.Text != "" ? txtJiHuaH_FGY.Text : "0");
                //计划水量
                _YS_QT_QUXIANJHYSQK.I_HEJIJHL = Convert.ToDecimal(txtJiHuaS_HJ.Text != "" ? txtJiHuaS_HJ.Text : "0");
                _YS_QT_QUXIANJHYSQK.I_GONGYEJHL = Convert.ToDecimal(txtJiHuaS_GY.Text != "" ? txtJiHuaS_GY.Text : "0");
                _YS_QT_QUXIANJHYSQK.I_FEIGONGYJHL = Convert.ToDecimal(txtJiHuaS_FGY.Text != "" ? txtJiHuaS_FGY.Text : "0");
                //新水量
                _YS_QT_QUXIANJHYSQK.I_HEJIXSL = Convert.ToDecimal(txtXinShuiL_HJ.Text != "" ? txtXinShuiL_HJ.Text : "0");
                _YS_QT_QUXIANJHYSQK.I_GONGYEXSL = Convert.ToDecimal(txtXinShuiL_GY.Text != "" ? txtXinShuiL_GY.Text : "0");
                _YS_QT_QUXIANJHYSQK.I_FEIGONGYXSL = Convert.ToDecimal(txtXinShuiL_FGY.Text != "" ? txtXinShuiL_FGY.Text : "0");
                //加价水量
                _YS_QT_QUXIANJHYSQK.I_HEJIJJL = Convert.ToDecimal(txtJiaJiaSL_HJ.Text != "" ? txtJiaJiaSL_HJ.Text : "0");
                _YS_QT_QUXIANJHYSQK.I_GONGYEJJL = Convert.ToDecimal(txtJiaJiaSL_GY.Text != "" ? txtJiaJiaSL_GY.Text : "0");
                _YS_QT_QUXIANJHYSQK.I_FEIGONGYJJL = Convert.ToDecimal(txtJiaJiaSL_FGY.Text != "" ? txtJiaJiaSL_FGY.Text : "0");
                //加价水费
                _YS_QT_QUXIANJHYSQK.N_HEJIJJF = Convert.ToDouble(txtJiaJiaSF_HJ.Text != "" ? txtJiaJiaSF_HJ.Text : "0");
                _YS_QT_QUXIANJHYSQK.N_GONGYEJJF = Convert.ToDouble(txtJiaJiaSF_GY.Text != "" ? txtJiaJiaSF_GY.Text : "0");
                _YS_QT_QUXIANJHYSQK.N_FEIGONGYJJF = Convert.ToDouble(txtJiaJiaSF_FGY.Text != "" ? txtJiaJiaSF_FGY.Text : "0");
                //计划完成率
                _YS_QT_QUXIANJHYSQK.N_JIHUAWCL = Convert.ToDouble(txtJiaHuaWCL.Text != "" ? txtJiaHuaWCL.Text : "0");
                //供水总量
                _YS_QT_QUXIANJHYSQK.I_GONGSHUIZL = Convert.ToDecimal(txtGongShuiZL.Text != "" ? txtGongShuiZL.Text : "0");
                //计划用水率
                _YS_QT_QUXIANJHYSQK.N_JIHUAYSL = Convert.ToDouble(txtJiaHuaYSL.Text != "" ? txtJiaHuaYSL.Text : "0");
                //水平衡户数
                _YS_QT_QUXIANJHYSQK.I_SHUIPINGHHS = Convert.ToInt32(txtShuiPingWCHS.Text != "" ? txtShuiPingWCHS.Text : "0");
                //节水项目数
                _YS_QT_QUXIANJHYSQK.I_JIESHUIXMS = Convert.ToInt32(txtJieShuiXMS.Text != "" ? txtJieShuiXMS.Text : "0");
                //最高日节水量
                _YS_QT_QUXIANJHYSQK.I_ZUIGAORJSL = Convert.ToDecimal(txtZuiGaoRJSL.Text != "" ? txtZuiGaoRJSL.Text : "0");
                //节水项目资金
                _YS_QT_QUXIANJHYSQK.N_JIESHUIZJ = Convert.ToDouble(txtJieShuiXMZJ.Text != "" ? txtJieShuiXMZJ.Text : "0");
                //自筹资金
                _YS_QT_QUXIANJHYSQK.N_ZICHOUZJ = Convert.ToDouble(txtZiChouZJ.Text != "" ? txtZiChouZJ.Text : "0");
                //节水器具安装件套数
                _YS_QT_QUXIANJHYSQK.I_JIESHUIQTS = Convert.ToInt32(txtJieShuiQJTS.Text != "" ? txtJieShuiQJTS.Text : "0");
                //节水器具安装日节水量
                _YS_QT_QUXIANJHYSQK.I_JIESHUIQJSL = Convert.ToDecimal(txtJieShuiQJSL.Text != "" ? txtJieShuiQJSL.Text : "0");
                //财政节水资金投入
                _YS_QT_QUXIANJHYSQK.N_CAIZHENGJSZJ = Convert.ToDouble(txtCaiZhengZJTR.Text != "" ? txtCaiZhengZJTR.Text : "0");

                _YS_QT_QUXIANJHYSQK.S_CAOZUOR = this.UserID.ToString();
                _YS_QT_QUXIANJHYSQK.D_CAOZUOSJ = BusinessTool.GetDataBaseDateTime();
                _SYS_LOGBLL.Log<YS_QT_QUXIANJHYSQK>(LoginInfo.CurrentUser, BusinessTool.WType.ToString(), "其他管理-计划用水情况", operateState, _YS_QT_QUXIANJHYSQK, null);
                bool success = _YS_QT_QUXIANJHYSQKBLL.InsertOrUpdate(_YS_QT_QUXIANJHYSQK, null);
                if (success)
                {
                    e.Result = e.Parameter + "|0|保存成功！";
                }
                else
                {
                    e.Result = e.Parameter + "|0|保存失败！";
                }
            }
            else if (e.Parameter == "edit2")
            {
                int id = Convert.ToInt32(this.hdCollection.Get("ID"));
                _YS_QT_QUXIANYSLYQK = _YS_QT_QUXIANYSLYQKBLL.SelectYS_QT_QUXIANYSLYQK(id, null);
                e.Result = string.Join("|", e.Parameter, "0", "success", _YS_QT_QUXIANYSLYQK.I_YM.ToString(), _YS_QT_QUXIANYSLYQK.S_QUXIAN.ToString(), _YS_QT_QUXIANYSLYQK.I_GONGYEXSL.ToString(),
                     _YS_QT_QUXIANYSLYQK.I_LENGQUEXSL.ToString(), _YS_QT_QUXIANYSLYQK.I_GONGYECFL.ToString(), _YS_QT_QUXIANYSLYQK.I_LENGQUEXHL.ToString(),
                     _YS_QT_QUXIANYSLYQK.N_GONGYECFL.ToString(), _YS_QT_QUXIANYSLYQK.N_LENGQUEXHL.ToString(), _YS_QT_QUXIANYSLYQK.I_GUOLUCQL.ToString(),
                     _YS_QT_QUXIANYSLYQK.I_GONGYIXSL.ToString(), _YS_QT_QUXIANYSLYQK.I_GUOLUHYL.ToString(), _YS_QT_QUXIANYSLYQK.I_GONGYIHYL.ToString(),
                     _YS_QT_QUXIANYSLYQK.N_GUOLUHYL.ToString(), _YS_QT_QUXIANYSLYQK.N_GONGYIHYL.ToString(), _YS_QT_QUXIANYSLYQK.I_GONGYEZCZ.ToString(),
                     _YS_QT_QUXIANYSLYQK.N_WANYUANXSL.ToString(), _YS_QT_QUXIANYSLYQK.I_CHENGSHIXSL.ToString(), _YS_QT_QUXIANYSLYQK.I_JIANJIEXSL.ToString(),
                   _YS_QT_QUXIANYSLYQK.I_CHENGSHICFL.ToString(), _YS_QT_QUXIANYSLYQK.I_JIANJIEXHL.ToString(), _YS_QT_QUXIANYSLYQK.N_CHENGSHICFL.ToString(),
                     _YS_QT_QUXIANYSLYQK.N_JIANJIEXHL.ToString(), _YS_QT_QUXIANYSLYQK.I_FEICHANGGSL.ToString(), _YS_QT_QUXIANYSLYQK.I_HAISHUILYL.ToString(),
                    _YS_QT_QUXIANYSLYQK.I_YUSHUILYL.ToString());
            }
            else if (e.Parameter == "del2")
            {
                int id = Convert.ToInt32(this.hdCollection.Get("ID"));
                _YS_QT_QUXIANYSLYQK = _YS_QT_QUXIANYSLYQKBLL.SelectYS_QT_QUXIANYSLYQK(id, null);

                //执行逻辑删除            
                _YS_QT_QUXIANYSLYQK.S_CAOZUOR = LoginInfo.CurrentUser.Account;
                _YS_QT_QUXIANYSLYQK.D_CAOZUOSJ = BusinessTool.GetDataBaseDateTime();
                _YS_QT_QUXIANYSLYQK.I_JLZT = -1;
                _SYS_LOGBLL.Log<YS_QT_QUXIANYSLYQK>(LoginInfo.CurrentUser, BusinessTool.WType.ToString(), "用水利用情况", OperateState.Delete, _YS_QT_QUXIANYSLYQK, null);
                if (_YS_QT_QUXIANYSLYQKBLL.InsertOrUpdate(_YS_QT_QUXIANYSLYQK))
                {


                }
                e.Result = e.Parameter + "|0|操作成功！";
            }
            else if (e.Parameter == "save2")
            {
                OperateState operateState;
                int id = Convert.ToInt32(this.hdCollection.Get("ID"));
                //添加
                if (id <= 0)
                {
                    _YS_QT_QUXIANYSLYQK.ID = 0;
                    _YS_QT_QUXIANYSLYQK.I_JLZT = 0;
                    operateState = OperateState.Add;
                }
                //修改
                else
                {
                    //修改操作
                    _YS_QT_QUXIANYSLYQK = _YS_QT_QUXIANYSLYQKBLL.SelectYS_QT_QUXIANYSLYQK(id, null);
                    operateState = OperateState.Modify;
                }

                //水量年月
                _YS_QT_QUXIANYSLYQK.I_YM = Convert.ToDecimal(txtShuiLiangNY2.Text);
                //区县
                _YS_QT_QUXIANYSLYQK.S_QUXIAN = cmbquxian2.Text;
                //工业用新水量
                _YS_QT_QUXIANYSLYQK.I_GONGYEXSL = Convert.ToDecimal(txtGongYeXSL.Text != "" ? txtGongYeXSL.Text : "0");
                //冷却新水量
                _YS_QT_QUXIANYSLYQK.I_LENGQUEXSL = Convert.ToDecimal(txtLengQueXSL.Text != "" ? txtLengQueXSL.Text : "0");
                //工业用水重复利用量
                _YS_QT_QUXIANYSLYQK.I_GONGYECFL = Convert.ToDecimal(txtGongYeCFL.Text != "" ? txtGongYeCFL.Text : "0");
                //间接冷却水循环量
                _YS_QT_QUXIANYSLYQK.I_LENGQUEXHL = Convert.ToDecimal(txtLengQueXHL.Text != "" ? txtLengQueXHL.Text : "0");
                //工业用水重复利用率
                _YS_QT_QUXIANYSLYQK.N_GONGYECFL = Convert.ToDouble(txtGongYeCFLv.Text != "" ? txtGongYeCFLv.Text : "0");
                //间接冷却水循环率
                _YS_QT_QUXIANYSLYQK.N_LENGQUEXHL = Convert.ToDouble(txtLengQueXHLv.Text != "" ? txtLengQueXHLv.Text : "0");
                //锅炉产汽量
                _YS_QT_QUXIANYSLYQK.I_GUOLUCQL = Convert.ToDecimal(txtGuoLuCQL.Text != "" ? txtGuoLuCQL.Text : "0");
                //工艺用新水量
                _YS_QT_QUXIANYSLYQK.I_GONGYIXSL = Convert.ToDecimal(txtGongYiXSL.Text != "" ? txtGongYiXSL.Text : "0");
                //锅炉蒸汽冷凝水回用量
                _YS_QT_QUXIANYSLYQK.I_GUOLUHYL = Convert.ToDecimal(txtGuoLuHYL.Text != "" ? txtGuoLuHYL.Text : "0");
                //工艺水回用量
                _YS_QT_QUXIANYSLYQK.I_GONGYIHYL = Convert.ToDecimal(txtGongYiHYL.Text != "" ? txtGongYiHYL.Text : "0");
                //锅炉蒸汽冷凝水回用率
                _YS_QT_QUXIANYSLYQK.N_GUOLUHYL = Convert.ToDouble(txtGuoLuHYLv.Text != "" ? txtGuoLuHYLv.Text : "0");
                //工艺水回用率
                _YS_QT_QUXIANYSLYQK.N_GONGYIHYL = Convert.ToDouble(txtGongYiHYLv.Text != "" ? txtGongYiHYLv.Text : "0");
                //工业总产值(现金)
                _YS_QT_QUXIANYSLYQK.I_GONGYEZCZ = Convert.ToDecimal(txtGongYeZCZ.Text != "" ? txtGongYeZCZ.Text : "0");
                //万元产值新水量
                _YS_QT_QUXIANYSLYQK.N_WANYUANXSL = Convert.ToDouble(txtWanYuanXSL.Text != "" ? txtWanYuanXSL.Text : "0");
                //城市公共用新水量
                _YS_QT_QUXIANYSLYQK.I_CHENGSHIXSL = Convert.ToDecimal(txtChengShiXSL.Text != "" ? txtChengShiXSL.Text : "0");
                //间接冷却用新水量
                _YS_QT_QUXIANYSLYQK.I_JIANJIEXSL = Convert.ToDecimal(txtLengQueXSL2.Text != "" ? txtLengQueXSL2.Text : "0");
                //城市公共用水重复利用量
                _YS_QT_QUXIANYSLYQK.I_CHENGSHICFL = Convert.ToDecimal(txtChengShiLYL.Text != "" ? txtChengShiLYL.Text : "0");
                //间接冷却水循环量
                _YS_QT_QUXIANYSLYQK.I_JIANJIEXHL = Convert.ToDecimal(txtLengQueXHL2.Text != "" ? txtLengQueXHL2.Text : "0");
                //城市公共用水重复利用率
                _YS_QT_QUXIANYSLYQK.N_CHENGSHICFL = Convert.ToDouble(txtChengShiLYLv.Text != "" ? txtChengShiLYLv.Text : "0");
                //间接冷却水循环率
                _YS_QT_QUXIANYSLYQK.N_JIANJIEXHL = Convert.ToDouble(txtLengQueXHLv2.Text != "" ? txtLengQueXHLv2.Text : "0");
                //非常规
                _YS_QT_QUXIANYSLYQK.I_FEICHANGGSL = Convert.ToDecimal(txtFeiChangGSL.Text != "" ? txtFeiChangGSL.Text : "0");
                //海水利用量
                _YS_QT_QUXIANYSLYQK.I_HAISHUILYL = Convert.ToDecimal(txtHaiShuiLYL.Text != "" ? txtHaiShuiLYL.Text : "0");
                //雨水利用量
                _YS_QT_QUXIANYSLYQK.I_YUSHUILYL = Convert.ToDecimal(txtYuShuiLYL.Text != "" ? txtYuShuiLYL.Text : "0");

                _YS_QT_QUXIANYSLYQK.S_CAOZUOR = this.UserID.ToString();
                _YS_QT_QUXIANYSLYQK.D_CAOZUOSJ = BusinessTool.GetDataBaseDateTime();
                _SYS_LOGBLL.Log<YS_QT_QUXIANYSLYQK>(LoginInfo.CurrentUser, BusinessTool.WType.ToString(), "其他管理-用水利用情况", operateState, _YS_QT_QUXIANYSLYQK, null);
                bool success = _YS_QT_QUXIANYSLYQKBLL.InsertOrUpdate(_YS_QT_QUXIANYSLYQK, null);
                if (success)
                {
                    e.Result = e.Parameter + "|0|保存成功！";
                }
                else
                {
                    e.Result = e.Parameter + "|0|保存失败！";
                }
            }
        }

        /// <summary>
        /// 计划用水情况grid刷新
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvJiHuaYS_CustomCallback(object sender, DevExpress.Web.ASPxGridViewCustomCallbackEventArgs e)
        {
            LoadGridDate1();
        }

        /// <summary>
        /// 用水利用情况grid刷新
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvYongShuiLYQK_CustomCallback(object sender, DevExpress.Web.ASPxGridViewCustomCallbackEventArgs e)
        {
            LoadGridDate2();
        }
        protected void btnExport_Click(object sender, EventArgs e)
        {
            int index = ASPxPageControl1.ActiveTabIndex;
            string sName = "";
            ASPxGridView gv = null;
            DataTable dt = null;
            if (index==0)
            {
                gv = this.gvJiHuaYS;
                dt = this.dtJiHuaYS;
                sName = "计划用水情况";
            }
            else if (index==1)
            {
                gv = this.gvYongShuiLYQK;
                dt = this.dtYongShuiLYQK;
                sName = "用水利用情况";
            }
            gv.DataSource = dt;
            gv.DataBind();
            ASPxGridViewExporter1.GridViewID = gv.ID;
            gv.Settings.ShowFooter = false;
            ASPxGridViewExporter1.WriteXlsToResponse(sName);
        }
    }
}